<template>
  <a-modal :maskClosable="false"
           title="详情"
           :width="1280"
           :visible="visible"
           :confirmLoading="confirmLoading"
           @ok="handleOk"
           @cancel="handleCancel"
           cancelText="关闭">

    <a-spin :spinning="confirmLoading">

      <a-tabs default-active-key="1">
        <a-tab-pane key="1" tab="心血管健康测评答题">
          <a-row v-for="item in estimate">
            <a-divider orientation="left">
              {{ item.questionType }}
            </a-divider>
            <a-row justify="start" v-for="(question,index) in item.questionList">
              <a-form-model-item :label="question.title" :label-col="{span: 4}" :wrapperCol="{span: 20 }">
                <a-checkbox v-for="(it,idx) in question.optionsList" :checked="it.izCheck" disabled="disabled">
                  {{ it.textContent }}
                </a-checkbox>
              </a-form-model-item>
            </a-row>
          </a-row>
        </a-tab-pane>
        <a-tab-pane key="2" tab="养疗方案及建议">
          <a-row v-for="(item,index) in suggest" :style="index>0?'margin-top: 50px':'margin-top: 0px'">
            <a-divider orientation="left">
              {{ item.label }}
            </a-divider>
            <a-row justify="start">
              <!---显示html内容-->
              <div v-html="item.key"></div>
            </a-row>
          </a-row>
        </a-tab-pane>
      </a-tabs>
    </a-spin>
  </a-modal>
</template>

<script>
import { httpAction, putAction, getAction, postAction } from '@/api/manage'
import { FormTypes } from '@/utils/JEditableTableUtil'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'hHisEstimateResultModal',
  mixins: [JeecgListMixin],
  data() {
    return {
      title: '操作',
      visible: false,
      model: {
        realName: ''
      },
      estimate: [],
      suggest: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
        style: 'width: 26%; line-height: 20px; white-space: normal'
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      layout: {
        labelCol: { span: 8 },
        wrapperCol: { span: 14 }
      },
      confirmLoading: false,
      disableMixinCreated: true,
      dataSource: [],
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '指标类型',
          align: 'center',
          dataIndex: 'keyName',
          width: 180
        },
        {
          title: '数据值',
          align: 'left',
          width: 500,
          dataIndex: 'itemList',
          customRender: function (text, record, index) {
            let textStr = '';
            console.log(record.itemList)
            record.itemList.forEach((item, index)=>{
              textStr+=item.indexName+"："+item.dataValue+ '\n'
            });

            const answer = textStr.split('\n')
            return answer.map((item) => {
              return <li>{item}</li>
            })
          },
        },
        {
          title: '是否达标',
          align: 'center',
          dataIndex: 'resultStatus',
          width: 120,
          customRender: (text, record, index) => {
            if (text == '1') {
              return '达标'
            } else {
              return '不达标'
            }
          }
        }
      ],
      url: {
        list: '/his/patient/healthy/data/dy/list'
      }
    }
  },
  created() {

  },
  methods: {
    edit(record) {
      const that = this
      that.visible = true
      getAction('/ch/evaluation/result/list/answer?reportCode=' + record.reportCode).then((res) => {
        if (res.success && res.result) {
          that.estimate = res.result
        }
      })
      getAction('/ch/evaluation/result/list/report/target/index?reportCode=' + record.reportCode).then((res) => {
        if (res.success && res.result) {
          that.dataSource = res.result
        }
      })

      getAction('/ch/evaluation/result/list/report/target/suggest?reportCode=' + record.reportCode).then((res) => {
        if (res.success && res.result) {
          that.suggest = res.result
        }
      })
      this.queryParam.busCode=record.reportCode;
      this.loadData();
    },
    close() {
      this.$emit('close')
      this.visible = false
    },
    handleOk() {
      const that = this
      that.close()
    },
    handleCancel() {
      this.close()
    }

  }
}
</script>

<style scoped>


</style>